package com.flnet.spsys.controller;


import com.flnet.spsys.entity.TbVipMember;
import com.flnet.spsys.service.ITbVipMemberService;
import com.flnet.spsys.utils.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.flnet.spsys.controller.BaseController;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 会员 前端控制器
 * </p>
 *
 * @author Qu Jingbin
 * @since 2021-03-15
 */
@RestController
@RequestMapping("/tb-vip-member")
public class TbVipMemberController extends BaseController {
    @Autowired
    private ITbVipMemberService iTbVipMemberService;

    @ResponseBody
    @PostMapping("/info")
    @CrossOrigin
    public Object showVipMemberInfo(){
        List<TbVipMember> tbVipMemberList = iTbVipMemberService.list();
        if(tbVipMemberList == null){
            return ResultJson.failure("获取失败！",null);
        }
        return ResultJson.success(tbVipMemberList);
    }

    @ResponseBody
    @PostMapping("/add")
    @CrossOrigin
    public boolean addVipMember(TbVipMember tbVipMember){
        tbVipMember.setId(3);
        tbVipMember.setName("小明");
        tbVipMember.setBirthday(null);
        tbVipMember.setPhone("15216548585");
        tbVipMember.setSex("male");
        tbVipMember.setState("1");
        tbVipMember.setVipType(1);
        tbVipMember.setEnd(null);
        tbVipMember.setStart(null);
        tbVipMember.setVipGrade(1);
        boolean save = iTbVipMemberService.save(tbVipMember);

        return save;
    }

}
